package com.anpy.user.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
 * 角色实体类
 */
@Data
@TableName(value = "T_ROLE")
@ApiModel(description = "角色信息")
public class RoleEntity {

    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty(value = "角色ID", example = "1")
    private Integer id;

    /**
     * 角色名称
     */
    @TableField(value = "name")
    @ApiModelProperty(value = "角色名称", required = true, example = "管理员")
    private String name;

    /**
     * 角色描述
     */
    @TableField(value = "description")
    @ApiModelProperty(value = "角色描述", example = "系统管理员，拥有所有权限")
    private String description;

    /**
     * 角色状态：true-启用，false-禁用
     */
    @TableField(value = "status")
    @ApiModelProperty(value = "角色状态：true-启用，false-禁用", required = true, example = "true")
    private Boolean status;

    /**
     * 创建时间
     */
    @TableField(value = "created_at")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间", example = "2025-02-26 16:30:00")
    private Date createdAt;

    /**
     * 权限菜单列表，不映射到数据库字段
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "权限菜单列表", example = "[\"user:view\", \"user:edit\"]")
    private List<String> permissions;
}
